package com.qdxwx.data.service.user;

import com.qdxwx.common.page.PageRequest;
import com.qdxwx.data.mapper.user.UserWorkHistoryMapper;
import com.qdxwx.models.user.UserWorkHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class UserWorkHistoryServiceImpl implements UserWorkHistoryService {

    @Autowired
    private UserWorkHistoryMapper userWorkHistoryMapper;

    @Override
    public int insert(UserWorkHistory userWorkHistory) {
        userWorkHistory.setCreateTime(LocalDateTime.now());
        return userWorkHistoryMapper.insertUserWorkHistory(userWorkHistory);
    }

    @Override
    public UserWorkHistory get(int id) {
        if (id < 1) return null;
        return userWorkHistoryMapper.selectById(id);
    }

    @Override
    public List<UserWorkHistory> getListByUserId(long userId) {
        return userWorkHistoryMapper.selectListByUserId(userId);
    }

    @Override
    public int count(long userId) {
        return userWorkHistoryMapper.selectCountByUserId(userId);
    }

    @Override
    public int updata(UserWorkHistory userWorkHistory) {
        return userWorkHistoryMapper.updataUserWorkHistory(userWorkHistory);
    }

    @Override
    public int delete(int id) {
        return userWorkHistoryMapper.deleteById(id);
    }
}
